package cn.echoedu.util;

import java.sql.Date;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;


public class DateUtil {
	public static Timestamp stringToDate(String datestr,String datetype){
		SimpleDateFormat dateformat = new SimpleDateFormat(datetype);
		Date date=null;
		try {
			java.util.Date utildate = (java.util.Date) dateformat.parse(datestr);
		   Timestamp timestamp  = new Timestamp(utildate.getTime());
		    return timestamp;
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	public static String dateToString(Timestamp date){
		SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
		String datestr = dateformat.format(date);
		return datestr;
	 }
	public static String dateToDetailString(Timestamp date){
		SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String datestr = dateformat.format(date);
		return datestr;
	}
	public static Timestamp getCurrentDate(){
		java.util.Date curDate = new java.util.Date();
		return new Timestamp(curDate.getTime());
	}
}
